<?php
/**
 * This file is part of Hyperf Mall.
 *
 * @link     https://gitee.com/scwlkj/hyperf_mall
 * @contact  hyperf_mall@163.com
 */

namespace App\JsonRpc;

use App\Constants\Category;
use App\Repository\ArticleCategoryRepository;
use Hyperf\RpcServer\Annotation\RpcService;
use App\JsonRpc\Interfaces\ArticleCategoryServiceInterface;

/**
 * @RpcService(name="Config::ArticleCategoryService", protocol="jsonrpc", server="jsonrpc")
 */
class ArticleCategoryService extends BaseService implements ArticleCategoryServiceInterface
{
    public function init()
    {
        $this->repository = ArticleCategoryRepository::getInstance();
    }

    /**
     * Notes: 获取分类树
     * Author: Bruce.z
     * DateTime: 2022/6/9 17:12
     * @return array
     */
    public function tree() :array
    {
        return $this->repository->getTree(Category::CATE_THREE);
    }

    /**
     * Notes: 获取分类树
     * Author: Bruce.z
     * DateTime: 2022/6/9 17:12
     * @return array
     */
    public function selectTree() :array
    {
        return $this->repository->makeSelectTree(Category::CATE_TWO);
    }
}
